package com.zhenlong.aop.controller;

import com.zhenlong.aop.Enum.OperLogEnum;
import com.zhenlong.aop.annotation.Log;
import com.zhenlong.aop.domain.SysLog;
import com.zhenlong.aop.service.Myservice;
import com.zhenlong.aop.vo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
public class TestController {
    @Autowired
    private Myservice myservice;
    @Log(value = "执行方法一",type = OperLogEnum.AUDIT)
    @GetMapping(value = "/one",produces = {"application/json;charset=UTF-8"})
    public void methodOne(@RequestBody @Valid User user) { }

    @Log(value = "执行方法二" ,type=OperLogEnum.BATCH_AUDIT)
    @GetMapping(value = "/two",produces = {"application/json;charset=UTF-8"})
    public void methodTwo(@RequestBody @Valid User user) throws InterruptedException {
        Thread.sleep(2000);
    }

    @Log("执行方法三")
    @GetMapping(value = "/three",produces = {"application/json;charset=UTF-8"})
    public void methodThree(@RequestBody @Valid User user, @RequestParam("age") String age) { }

    @Log(value = "fileImport" ,type = OperLogEnum.BATCH_AUDIT)
    @PostMapping(value = "/fileImport",produces = {"application/json;charset=UTF-8"})
    public String testGetFileImport(@RequestBody String request){
        return "ok";
    }
    @Log(value = "查询",type = OperLogEnum.QUERY)
    @GetMapping(value = "/queryAll",produces = {"application/json;charset=UTF-8"})
    public List<SysLog> queryAll(@RequestBody @Valid User user) throws Exception{
        return myservice.queryAll(user);
    }
}
